%%%%%
%%%%% Replication code for 
%%%%% Constituency Diversity, District Magnitude, and Voter Coordination 
%%%%% Joshua D Potter
%%%%% Forthcoming in the British Journal of Political Science
%%%%%


% database for analysis formatted in Stata 
% commands given in Stata code below
% graphics generated in R using marginal effects values generated in Stata 


% percentage of voters surveyed (for cut-point checks)

gen persurvey = tot_n / dtv

% 1 percent = 0.0000588
% 5 percent = 0.0001199
% 10 percent = 0.0001436


% the "drop" variables indicate M=0, M=missing, M=national minority district, or election year that predates CSES survey coverage, i.e. those districts that are inappropriate to include for theoretical reasons   

% Model 1, Table 1 in main text and data for marginal effects plots

xtmixed cordprod tot_div log_dm div_dm newshr fed crossdiv comp if drop!=1 & drop2!=1 & persurvey > 0.0000588 & tot_div!=., level(95), || cnty:, || distname:

lincom tot_div + (0)*div_dm, level(90)
lincom tot_div + (0.301)*div_dm, level(90)
lincom tot_div + (0.477)*div_dm, level(90)
lincom tot_div + (0.602)*div_dm, level(90)
lincom tot_div + (0.699)*div_dm, level(90)
lincom tot_div + (0.778)*div_dm, level(90)
lincom tot_div + (0.845)*div_dm, level(90)
lincom tot_div + (0.903)*div_dm, level(90)
lincom tot_div + (0.954)*div_dm, level(90)
lincom tot_div + (1.0)*div_dm, level(90)
lincom tot_div + (1.041)*div_dm, level(90)
lincom tot_div + (1.079)*div_dm, level(90)
lincom tot_div + (1.114)*div_dm, level(90)
lincom tot_div + (1.146)*div_dm, level(90)
lincom tot_div + (1.176)*div_dm, level(90)


% Model 2, Table 1 in main text and data for marginal effects plots

gen dmlow2 = . 
replace dmlow2 = 0 if dm > 5
replace dmlow2 = 1 if dm <= 5
replace dmlow2 = . if dm == .

xtmixed cordprod tot_div dmlow2 tot_div_low2 newshr fed crossdiv comp if drop!=1 & drop2!=1 & persurvey > 0.0000588 & tot_div!=., level(95), || cnty:, || distname:

lincom tot_div + (0)*tot_div_low2, level(90)
lincom tot_div + (1)*tot_div_low2, level(90)


% Appendix 5 Robustness Check

xtmixed cordprod tot_div log_dm div_dm newshr fed crossdiv comp if drop!=1 & drop2!=1 & persurvey > 0.0000588 & tot_div!=. & dm>1, level(95), || cnty:, || distname:

lincom tot_div + (0)*div_dm, level(90)
lincom tot_div + (0.301)*div_dm, level(90)
lincom tot_div + (0.477)*div_dm, level(90)
lincom tot_div + (0.602)*div_dm, level(90)
lincom tot_div + (0.699)*div_dm, level(90)
lincom tot_div + (0.778)*div_dm, level(90)
lincom tot_div + (0.845)*div_dm, level(90)
lincom tot_div + (0.903)*div_dm, level(90)
lincom tot_div + (0.954)*div_dm, level(90)
lincom tot_div + (1.0)*div_dm, level(90)
lincom tot_div + (1.041)*div_dm, level(90)
lincom tot_div + (1.079)*div_dm, level(90)
lincom tot_div + (1.114)*div_dm, level(90)
lincom tot_div + (1.146)*div_dm, level(90)
lincom tot_div + (1.176)*div_dm, level(90)

xtmixed cordprod tot_div dmlow2 tot_div_low2 newshr fed crossdiv comp if drop!=1 & drop2!=1 & persurvey > 0.0000588 & tot_div!=. & dm>1, level(95), || cnty:, || distname:

lincom tot_div + (0)*tot_div_low2, level(90)
lincom tot_div + (1)*tot_div_low2, level(90)


% Appendix 6 Robustness Check

xtmixed cordprod tot_div log_dm div_dm newshr fed crossdiv comp if cnty!="Austria" & drop!=1 & drop2!=1 & persurvey > 0.0000588 & tot_div!=., level(95), || cnty:, || distname:
xtmixed cordprod tot_div log_dm div_dm newshr fed crossdiv comp if cnty!="Croatia" & drop!=1 & drop2!=1 & persurvey > 0.0000588 & tot_div!=., level(95), || cnty:, || distname:
xtmixed cordprod tot_div log_dm div_dm newshr fed crossdiv comp if cnty!="Finland" & drop!=1 & drop2!=1 & persurvey > 0.0000588 & tot_div!=., level(95), || cnty:, || distname:
xtmixed cordprod tot_div log_dm div_dm newshr fed crossdiv comp if cnty!="Ireland" & drop!=1 & drop2!=1 & persurvey > 0.0000588 & tot_div!=., level(95), || cnty:, || distname:
xtmixed cordprod tot_div log_dm div_dm newshr fed crossdiv comp if cnty!="Norway" & drop!=1 & drop2!=1 & persurvey > 0.0000588 & tot_div!=., level(95), || cnty:, || distname:
xtmixed cordprod tot_div log_dm div_dm newshr fed crossdiv comp if cnty!="Poland" & drop!=1 & drop2!=1 & persurvey > 0.0000588 & tot_div!=., level(95), || cnty:, || distname:
xtmixed cordprod tot_div log_dm div_dm newshr fed crossdiv comp if cnty!="Portugal" & drop!=1 & drop2!=1 & persurvey > 0.0000588 & tot_div!=., level(95), || cnty:, || distname:
xtmixed cordprod tot_div log_dm div_dm newshr fed crossdiv comp if cnty!="Romania" & drop!=1 & drop2!=1 & persurvey > 0.0000588 & tot_div!=., level(95), || cnty:, || distname:
xtmixed cordprod tot_div log_dm div_dm newshr fed crossdiv comp if cnty!="Slovenia" & drop!=1 & drop2!=1 & persurvey > 0.0000588 & tot_div!=., level(95), || cnty:, || distname:
xtmixed cordprod tot_div log_dm div_dm newshr fed crossdiv comp if cnty!="Spain" & drop!=1 & drop2!=1 & persurvey > 0.0000588 & tot_div!=., level(95), || cnty:, || distname:
xtmixed cordprod tot_div log_dm div_dm newshr fed crossdiv comp if cnty!="Sweden" & drop!=1 & drop2!=1 & persurvey > 0.0000588 & tot_div!=., level(95), || cnty:, || distname:
xtmixed cordprod tot_div log_dm div_dm newshr fed crossdiv comp if cnty!="Switzerland" & drop!=1 & drop2!=1 & persurvey > 0.0000588 & tot_div!=., level(95), || cnty:, || distname:


% Appendix 7 Robustness Check

xtmixed cordprod tot_div log_dm div_dm newshr lag_vol_b  elec1 elec2 elec3 elec4 fed crossdiv comp if cnty!="Iceland" & drop!=1 & persurvey > 0.0000588 & tot_div!=., level(95), || cnty:, || distname:

xtmixed cordprod tot_div dmlow2 tot_div_low2 newshr lag_vol_b elec1 elec2 elec3 elec4 fed crossdiv comp if cnty!="Iceland" & drop!=1 & persurvey > 0.0000588 & tot_div!=., level(95), || cnty:, || distname:


% Appendix 8 Robustness Check

% dropping the cut point entirely 
xtmixed cordprod tot_div log_dm div_dm newshr fed crossdiv comp if drop!=1 & drop2!=1 & tot_div!=., level(95), || cnty:, || distname:

% dropping less than 5-percent response at district level
xtmixed cordprod tot_div log_dm div_dm newshr fed crossdiv comp if drop!=1 & drop2!=1 & persurvey > 0.0001199 & tot_div!=., level(95), || cnty:, || distname:

% dropping less than 10-percent response at district level
xtmixed cordprod tot_div log_dm div_dm newshr fed crossdiv comp if drop!=1 & drop2!=1 & persurvey > 0.0001436 & tot_div!=., level(95), || cnty:, || distname:


% Appendix 9 Robustness Check

gen hope1000 = hopeless/1000

xtmixed hope1000 tot_div log_dm div_dm newshr fed crossdiv comp if drop!=1 & drop2!=1 & persurvey > 0.0000588 & tot_div!=., level(95), || cnty:, || distname:

xtmixed hope1000 tot_div dmlow2 tot_div_low2 newshr fed crossdiv comp if drop!=1 & drop2!=1 & persurvey > 0.0000588 & tot_div!=., level(95), || cnty:, || distname:





